package com.pure.common.syn;

import java.util.concurrent.CopyOnWriteArrayList;

/**
 * @description: TestJUC CopyOnWriteArrayList
 * @date: 2022-08-09 11:01
 * @since 1.2.0
 **/
public class TestJUC {

    public static void main(String[] args) {
        CopyOnWriteArrayList<String> list = new CopyOnWriteArrayList<String>();
        for (int i = 0; i < 10000; i++) {
            new Thread(() -> {
                list.add(Thread.currentThread().getName());
            }).start();
        }

        try {
            Thread.sleep(3000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }

        System.out.println("输出 list size : " + list.size());

    }
}
